// store/getters.js
import { getters as permissionGetters } from './modules/permission.js';

const getters = {
  token: (state) => state.user.token,
  name: (state) => state.user.username
  // 这里可以添加其他全局 getters
};

// 合并 permission 模块的 getters
console.log('permissionGetters:', permissionGetters);
const namespacedGetters = {};
permissionGetters &&
  Object.keys(permissionGetters).forEach((key) => {
    namespacedGetters[`permission/${key}`] = (state) => {
      return permissionGetters[key](state.permission);
    };
  });

// 将合并后的 getters 与全局 getters 合并
Object.assign(getters, namespacedGetters);

export default getters;
